package cn.kkcxy.blog.system.service.impl;

import cn.dev33.satoken.stp.StpInterface;
import cn.kkcxy.blog.system.service.AuthService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @BelongsProject: kkcxy-blog
 * @BelongsPackage: cn.kkcxy.blog.system.service.impl
 * @Author: kkcxy
 * @CreateTime: 2024-09-13 00:48
 * @Description: Sa Token 角色权限获取实现
 * @Version: 1.0
 */
@Slf4j
@Component
public class StpInterfaceImpl implements StpInterface {

    /**
     * auth service
     */
    @Resource
    private AuthService authService;

    /**
     * 权限集合
     */
    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        log.info("StpInterfaceImpl.getPermissionList: {}, {}", loginId, loginType);
        return authService.getPermissionList(Long.parseLong(String.valueOf(loginId)));
    }

    /**
     * 角色集合
     */
    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        log.info("StpInterfaceImpl.getRoleList: {}, {}", loginId, loginType);
        return authService.getRoleList(Long.parseLong(String.valueOf(loginId)));
    }
}
